<?php

/**
 * This is the model class for table "tbl_glucometers_inpatients".
 *
 * The followings are the available columns in table 'tbl_glucometers_inpatients':
 * @property string $pk_glucometers_inpatient_id
 * @property string $fk_inpatient_bed_id
 * @property integer $glucometer_inpatient_status
 * @property string $glucometer_unique_number
 * @property string $version
 * @property string $value_type_code
 * @property string $instrument_model
 * @property string $create_time
 * @property string $update_time
 */
class TblGlucometersInpatients extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_glucometers_inpatients';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('pk_glucometers_inpatient_id, glucometer_inpatient_status, glucometer_unique_number, version, value_type_code, instrument_model, create_time, update_time', 'required'),
			array('glucometer_inpatient_status', 'numerical', 'integerOnly'=>true),
			array('pk_glucometers_inpatient_id, fk_inpatient_bed_id', 'length', 'max'=>20),
			array('glucometer_unique_number, instrument_model', 'length', 'max'=>100),
			array('version, value_type_code', 'length', 'max'=>50),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('pk_glucometers_inpatient_id, fk_inpatient_bed_id, glucometer_inpatient_status, glucometer_unique_number, version, value_type_code, instrument_model, create_time, update_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'pk_glucometers_inpatient_id' => 'Pk Glucometers Inpatient',
			'fk_inpatient_bed_id' => 'Fk Inpatient Bed',
			'glucometer_inpatient_status' => 'Glucometer Inpatient Status',
			'glucometer_unique_number' => 'Glucometer Unique Number',
			'version' => 'Version',
			'value_type_code' => 'Value Type Code',
			'instrument_model' => 'Instrument Model',
			'create_time' => 'Create Time',
			'update_time' => 'Update Time',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('pk_glucometers_inpatient_id',$this->pk_glucometers_inpatient_id,true);
		$criteria->compare('fk_inpatient_bed_id',$this->fk_inpatient_bed_id,true);
		$criteria->compare('glucometer_inpatient_status',$this->glucometer_inpatient_status);
		$criteria->compare('glucometer_unique_number',$this->glucometer_unique_number,true);
		$criteria->compare('version',$this->version,true);
		$criteria->compare('value_type_code',$this->value_type_code,true);
		$criteria->compare('instrument_model',$this->instrument_model,true);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return TblGlucometersInpatients the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
